#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int Pow(int x, int y)
{
	int i = 0;
	int result = 1;
	for (i = 0; i <y; i++)
	{
		result*=x;
	}
	return result;
}

int Jud_six(int n)
{
	int count = 0;
	if (n / 6 == 0)
	{
		return 0;
    }
	else
	{
		while (n / 6)
		{
			n = n / 6 ;
			count++;
		}
	}

	return count;
	

}
int Jud_print(int n, int ret1)
{
	int ret = Pow(6, ret1);
	if (ret1 == 0)
	{
		
		printf("%d ", n % 6);

	}
	else
	{
		
		  printf("%d ", n / ret);
		  printf("%d ", n % ret / Pow(6, ret1 - 1));
		  printf("%d ", n % ret % Pow(6, ret1 - 1));


	     
		
	}


}


int main()
{
	int n = 0;
	scanf("%d", &n);
	int ret1=Jud_six(n);
    Jud_print(n, ret1);
	


	return 0;
}